/*     */ package eos.moe.dragoncore.tweaker;
/*     */ 
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import net.minecraft.launchwrapper.IClassTransformer;
/*     */ import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
/*     */ import net.minecraftforge.fml.relauncher.FMLRelaunchLog;
/*     */ import org.objectweb.asm.ClassReader;
/*     */ import org.objectweb.asm.ClassVisitor;
/*     */ import org.objectweb.asm.ClassWriter;
/*     */ import org.objectweb.asm.tree.ClassNode;
/*     */ import org.objectweb.asm.tree.MethodNode;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class TransformerManager
/*     */   implements IClassTransformer
/*     */ {
/*  25 */   private Map<String, Map<String, IMethodTransformer>> map = new HashMap<>();
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public byte[] transform(String str1, String str2, byte[] arrayOfByte) {
/*  64 */     if (!this.map.containsKey(str2)) return arrayOfByte; 
/*  65 */     FMLRelaunchLog.info("[CSL DEBUG] CLASS %s will be transformed", new Object[] { str2 });
/*  66 */     Map map = this.map.get(str2);
/*     */     
/*  68 */     ClassReader classReader = new ClassReader(arrayOfByte);
/*  69 */     ClassNode classNode = new ClassNode();
/*  70 */     classReader.accept((ClassVisitor)classNode, 0);
/*     */ 
/*     */     
/*  73 */     List list = new ArrayList();
/*  74 */     list.addAll(classNode.methods);
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     
/*  80 */     for (MethodNode methodNode : list) {
/*  81 */       String str3 = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(str1, methodNode.name, methodNode.desc);
/*  82 */       String str4 = FMLDeobfuscatingRemapper.INSTANCE.mapMethodDesc(methodNode.desc);
/*  83 */       if (map.containsKey(str3 + str4)) {
/*     */         try {
/*  85 */           FMLRelaunchLog.info("[CSL DEBUG] Transforming method %s in class %s(%s)", new Object[] { str3 + str4, str1, str2 });
/*  86 */           ((IMethodTransformer)map.get(str3 + str4)).transform(classNode, methodNode);
/*  87 */           FMLRelaunchLog.info("[CSL DEBUG] Successfully transformed method %s in class %s(%s)", new Object[] { str3 + str4, str1, str2 });
/*  88 */         } catch (Exception exception) {
/*  89 */           FMLRelaunchLog.warning("[CSL DEBUG] An error happened when transforming method %s in class %s(%s). The whole class was not modified.", new Object[] { str3 + str4, str1, str2 });
/*  90 */           exception.printStackTrace();
/*  91 */           return arrayOfByte;
/*     */         } 
/*     */       }
/*     */     } 
/*     */     
/*  96 */     ClassWriter classWriter = new ClassWriter(3);
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 103 */     classNode.accept(classWriter);
/*     */ 
/*     */     
/* 106 */     arrayOfByte = classWriter.toByteArray();
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 113 */     return arrayOfByte;
/*     */   }
/*     */   
/*     */   public static interface IMethodTransformer {
/*     */     void transform(ClassNode param1ClassNode, MethodNode param1MethodNode);
/*     */   }
/*     */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\eos\moe\dragoncore\tweaker\TransformerManager.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */